package com.example.administrator.shihuo.fragments;


import android.graphics.Bitmap;
import android.nfc.Tag;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.administrator.shihuo.R;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.BitmapCallback;

/**
 * A simple {@link Fragment} subclass.
 */
public class HomeVPFragment extends Fragment {


    private static final String TAG = HomeVPFragment.class.getSimpleName();
    private ImageView imageView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_v, container, false);
        imageView = ((ImageView) view.findViewById(R.id.vpFragment_imageview));
        Bundle bundle = getArguments();
        String path = bundle.getString("path");
        Log.e(TAG,"HomeVPFragment=============="+path);

        OkHttpUtils.get().url(path).tag("iamge").build().execute(new BitmapCallback() {
            @Override
            public void onError(Request request, Exception e) {
                Toast.makeText(getContext(), "下载失败", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onResponse(Bitmap response) {
                if (response != null) {
                    imageView.setImageBitmap(response);
                }

            }
        });
        return view;
    }

}
